package com.byedu.course;

import com.byedu.domain.course.GuideInforDO;
import com.byedu.domain.course.JobInforDO;
import com.byedu.domain.course.vo.GuideInforVO;
import com.byedu.mapper.course.GuideInforMapper;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Luo on 2017-09-21.
 */
@Service
public class GuideInforService {

    @Autowired
    GuideInforMapper guideInforMapper;

    public List<GuideInforVO> getGuideInforList(GuideInforDO guideInforDO) {

        return convertDoListToVoList(guideInforMapper.getGuideInforList(guideInforDO));
    }
    public GuideInforDO getGuideInforbyId(int id) {

        return guideInforMapper.getGuideInforbyId(id);
    }


    public int updateGuideInfor(GuideInforDO guideInforDO){
        return guideInforMapper.updateGuideInfor(guideInforDO);
    }

    public int saveGuideInfor(GuideInforDO guideInforDO){
        return guideInforMapper.saveGuideInfor(guideInforDO);
    }
    public List<GuideInforVO> getGuideInforLists() {

        return convertDoListToVoList(guideInforMapper.getGuideInforLists());
    }

    public List<GuideInforVO> convertDoListToVoList(List<GuideInforDO> guideInforDOList) {
        List<GuideInforVO> guideInforVOList = new ArrayList<GuideInforVO>();
        if (CollectionUtils.isNotEmpty(guideInforDOList)) {

            for (GuideInforDO guideInforDO : guideInforDOList) {
                GuideInforVO guideInforVO = new GuideInforVO(guideInforDO);
                guideInforVOList.add(guideInforVO);
            }

            return guideInforVOList;
        }
        return guideInforVOList;
    }
}
